package com.fdb.efp.nls.service.impl;

import com.fdb.efp.nls.service.domain.WsApproveackNotify;
import com.fdb.efp.nls.service.facade.WsApproveackNotifyService;
import com.fdb.efp.nls.service.vo.WsApproveackNotifyVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.WsApproveackNotifyDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;


/**
 * Service Impl: 网商授信终审信息表服务实现
 * @author ligm
 * @date 2019-08-08 
 */
@Service("wsApproveackNotifyService")
public class WsApproveackNotifyServiceImpl implements WsApproveackNotifyService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(WsApproveackNotifyServiceImpl.class);

	@Autowired
	private WsApproveackNotifyDao wsApproveackNotifyDao;

   	/**
	 * 新增数据 
     * @param inWsApproveackNotifyVo
     * @return 
	 */
	public int insertWsApproveackNotify(WsApproveackNotifyVO inWsApproveackNotifyVo) {
		logger.debug("当前新增数据为:"+ inWsApproveackNotifyVo.toString());
		int num = 0;
		try {
			WsApproveackNotify wsApproveackNotify = new WsApproveackNotify();
			beanCopy(inWsApproveackNotifyVo, wsApproveackNotify);
			num = wsApproveackNotifyDao.insertWsApproveackNotify(wsApproveackNotify);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inWsApproveackNotifyVo
 	 * @return
	 */
	public int deleteByPk(WsApproveackNotifyVO inWsApproveackNotifyVo) {
		logger.debug("当前删除数据条件为:"+ inWsApproveackNotifyVo);
		int num = 0;
		try {
			WsApproveackNotify wsApproveackNotify = new WsApproveackNotify();
			beanCopy(inWsApproveackNotifyVo, wsApproveackNotify);
			num = wsApproveackNotifyDao.deleteByPk(wsApproveackNotify);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApproveackNotifyVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inWsApproveackNotifyVo
	 * @return 
	 */  
	public int updateByPk(WsApproveackNotifyVO inWsApproveackNotifyVo) {
		logger.debug("当前修改数据为:"+ inWsApproveackNotifyVo.toString());
		int num = 0;
		try {
			WsApproveackNotify wsApproveackNotify = new WsApproveackNotify();
			beanCopy(inWsApproveackNotifyVo, wsApproveackNotify);
			num = wsApproveackNotifyDao.updateByPk(wsApproveackNotify);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApproveackNotifyVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param wsApproveackNotify
	 * @return 
	 */
	public WsApproveackNotifyVO queryByPk(WsApproveackNotifyVO inWsApproveackNotifyVo) {
		
		logger.debug("当前查询参数信息为:"+ inWsApproveackNotifyVo);
		try {
			WsApproveackNotify queryWsApproveackNotify = new WsApproveackNotify();
			beanCopy(inWsApproveackNotifyVo, queryWsApproveackNotify);
			WsApproveackNotify queryRslWsApproveackNotify = wsApproveackNotifyDao.queryByPk(queryWsApproveackNotify);
			if (Objects.nonNull(queryRslWsApproveackNotify)) {
				WsApproveackNotifyVO outWsApproveackNotifyVo = beanCopy(queryRslWsApproveackNotify, new WsApproveackNotifyVO());
				logger.debug("当前查询结果为:"+ outWsApproveackNotifyVo.toString());
				return outWsApproveackNotifyVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param wsApproveackNotify
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<WsApproveackNotifyVO> queryAllByLevelOne(WsApproveackNotifyVO wsApproveackNotifyVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<WsApproveackNotifyVO> list = null;
		try {
			List<WsApproveackNotify> wsApproveackNotifys = wsApproveackNotifyDao.queryAllByLevelOneByPage(wsApproveackNotifyVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ wsApproveackNotifys.size());
			pageSet(wsApproveackNotifys, wsApproveackNotifyVo);
			list = (List<WsApproveackNotifyVO>) beansCopy(wsApproveackNotifys, WsApproveackNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param wsApproveackNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackNotifyVO> queryAllByLevelTwo(WsApproveackNotifyVO wsApproveackNotifyVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<WsApproveackNotify> wsApproveackNotifys = wsApproveackNotifyDao.queryAllByLevelTwoByPage(wsApproveackNotifyVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+wsApproveackNotifys.size());
		List<WsApproveackNotifyVO> list = null;
		try {
			pageSet(wsApproveackNotifys, wsApproveackNotifyVo);
			list = (List<WsApproveackNotifyVO>) beansCopy(wsApproveackNotifys, WsApproveackNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param wsApproveackNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackNotifyVO> queryAllByLevelThree(WsApproveackNotifyVO wsApproveackNotifyVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<WsApproveackNotify> wsApproveackNotifys = wsApproveackNotifyDao.queryAllByLevelThreeByPage(wsApproveackNotifyVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ wsApproveackNotifys.size());
		List<WsApproveackNotifyVO> list = null;
		try {
			pageSet(wsApproveackNotifys, wsApproveackNotifyVo);
			list = (List<WsApproveackNotifyVO>) beansCopy(wsApproveackNotifys, WsApproveackNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param wsApproveackNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackNotifyVO> queryAllByLevelFour(WsApproveackNotifyVO wsApproveackNotifyVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApproveackNotify> wsApproveackNotifys = wsApproveackNotifyDao.queryAllByLevelFourByPage(wsApproveackNotifyVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApproveackNotifys.size());
		List<WsApproveackNotifyVO> list = null;
		try {
			pageSet(wsApproveackNotifys, wsApproveackNotifyVo);
			list = (List<WsApproveackNotifyVO>) beansCopy(wsApproveackNotifys, WsApproveackNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param wsApproveackNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackNotifyVO> queryAllByLevelFive(WsApproveackNotifyVO wsApproveackNotifyVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApproveackNotify> wsApproveackNotifys = wsApproveackNotifyDao.queryAllByLevelFiveByPage(wsApproveackNotifyVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApproveackNotifys.size());
		List<WsApproveackNotifyVO> list = null;
		try {
			pageSet(wsApproveackNotifys, wsApproveackNotifyVo);
			list = (List<WsApproveackNotifyVO>) beansCopy(wsApproveackNotifys, WsApproveackNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

	@Override
	public WsApproveackNotifyVO queryByApplyNo(String applyNo) {
		logger.debug("当前查询参数信息为:"+ applyNo);
		try {
			WsApproveackNotify queryRslWsApplyNotify = wsApproveackNotifyDao.queryByApplyNo(applyNo);
			if (Objects.nonNull(queryRslWsApplyNotify)) {
				WsApproveackNotifyVO outWsApplyNotifyVo = beanCopy(queryRslWsApplyNotify, new WsApproveackNotifyVO());
				logger.debug("当前查询结果为:"+ outWsApplyNotifyVo.toString());
				return outWsApplyNotifyVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}
}
